--[[
	用lua的table来表明mysql的数据库结构，主要起两个作用
	1，启动的时候做数据库版本检查
	2，读写数据的时候生成对应的sql语句
	3，单行表的时候插入默认值
	具体信息和内容看sql
	表现在这里的数据结构就三种，整数，字符串，talbe。
	table类型，在lua里面表现是数组，在mysql，redis里面以json字符串存储
	storage :1 只存储在redis中，2，只存储在myql中，3，redis,mysql都存储，理论上应该只有1，3
]]

local dbstruct

dbstruct = {
    --rs_user
	rs_user = {
		fields = {
			rid = 0,
			username = '',
			cpass = '',	
			saltpass = '',
            phonenum = nil,
            phonecpass = '',
            phonesaltpass = '',
			guestmobileid = '',
			gategroup = 1,
			create_time = 0,
		},
		storage = 3,
	},
	-- rs_info
	rs_info = {
		fields = {
			rid = 0,
			rolename = "_",
			level = 0,
			logo = '1',
			sex = 2,
			intro = '',
			recommrid = 0,
			agencyrid = 0,	-- 他的上级代理（推广）是多少
			agencylevel = 0,-- 如果=0，说明是普通用户， 1：试用推广员，2，推广员，3，馆主
			phonenum = nil,
			realname = '',
			idcardtype = 0,
			idcardnum = '',
			idtrue = 0,
			logoframe = 0,		--头像框id
            alipayaccount = '', --支付宝账号
            weixinaccount = '', --微信账号
			bankcardaccount = '',--银行卡账号
            bankcard_bankname = '',--银行卡名
            is_vip = 0,
			pkgid = 0,
			create_time = 0,
		},
		storage = 3,
	},
    rs_otherinfo = {
        fields = {
            upvoted_num = 0,    --被赞数
            downvoted_num = 0,  --被踩数
            gamedata = '{}',    --游戏数据
            massmail_list = '{}',--群发邮件列表,值为群发邮件的keyid
            alipay_realname = '',   --支付宝实名
            bankcard_realname = '', --银行卡实名
			weixin_realname = '',   --微信实名
			rid = 0,
            create_time = 0,
        },
        storage = 3,
    },
	rs_money = {
		fields = {
			rid = 0,
			diamond = 0,
			coin = 0,
			fangka = 0,
			lock_password = '', -- 银行密码 md5(md5(plaintxt) .. rid)
			lock_diamond = 0,
			lock_coin = 0,
            normal_charge = 0,-- 游戏内直充总金额
            basemoney = 0,    -- 底钱，即玩家不能提现的钱
            total_win = 0,    -- 游戏总赢取
            total_lose = 0,   -- 游戏总输值
            agency_charge = 0,-- 代理奖励转入总金额
            system_charge = 0,-- 系统奖励总金额
            total_withdraw = 0,     -- 总提现金额
            total_servicefee = 0,   -- 总提现手续费 
			today_water = 0,		-- 今日总流水
			limit_chipvalue = 0,	-- 打码限额值
			total_chipvalue = 0,	-- 累计打码值
			base_chipvalue = 0,		-- 基础打码值
			phase_chipvalue = 0,	-- 阶段打码值
			create_time = 0,
		},
		storage = 3,
	},
	rm_mail = {
		fields = {
			rid = 0,
			keyid = 0,
			sendrid = 0, -- 默认是0 ，是系统
			sendname = 'admin',
			subject = 'subjet',
			content = 'content',
			attach_json = '{}', -- 数据库里存放的是json编码后的字符串
            mail_type = 0,      --默认0，系统邮件
			create_time = 0,
		},
		storage = 3,
	},
	rs_readmail = {
		fields = {
			rid = 0,
			last_sendtime = 0,	-- 最后给他发送邮件的时间
			last_gettime = 0,	-- 用户getmaillist行为的时间
			create_time = 0,
		},
		storage = 3, --1,
	},
	rm_diamondresult = {
		fields = {
			rid = 0,
			keyid = 0,
			game_type = '',
			table_code = 0,
			table_tradeid = 0,
			self_result = 0,
			other_result_json = '{}',
			replay_logname = '',
			create_time = 0,
		},
		storage = 3, --1,
	},
    rm_coinresult = {
		fields = {
			rid = 0,
			keyid = 0,
			game_type = '',
			table_code = 0,
			table_tradeid = 0,
			self_result = 0,
            self_otherresult = 0,
			other_result_json = '{}',
			replay_logname = '',
			create_time = 0,
		},
		storage = 3, --1,
	},
	rm_fangkaresult = {
		fields = {
			rid = 0,
			keyid = 0,
			game_type = '',
			table_code = 0,
			table_tradeid = 0,
			self_result = 0,
			other_result_json = '{}',
			create_time = 0,
		},
		storage = 3, --1,
	},
    rs_prop = { --道具表
        fields = {
            rid = 0,
            prop_list_json = '{}',  --道具列表，json编码字符串
            create_time = 0,
        },
        storage = 3,
	},
	rs_drresult = {        --达人
		fields = {
			rid = 0,
            maxscore = 0,          --最高分数
			create_time = 0,
		},
		storage = 3, --1,
	},
    rs_ddsresult = {        --打地鼠
		fields = {
			rid = 0,
            maxscore = 0,          --最高分数
			create_time = 0,
		},
		storage = 3, --1,
	},
    rs_dfjresult = {        --打飞机
		fields = {
			rid = 0,
            maxscore = 0,          --最高分数
			create_time = 0,
		},
		storage = 3, --1,
	},
	rs_llkresult = {        --连连看
		fields = {
			rid = 0,
            maxscore = 0,          --最高分数
			create_time = 0,
		},
		storage = 3, --1,
	},
	rs_jackpot = {			--游戏奖池数据
		fields = {
			rid = 0,
			potnum = 0,
			create_time = 0,
		},
		storage = 3, 	---1
	},
    rs_robot = {			--机器人表
		fields = {
			rid = 0,
            username = '',
            cpass = '',
			create_time = 0,
		},
		storage = 3, 	---1
	},
    rm_withdraw = {     --提现表
        fields = {
			rid = 0,
			keyid = 0,
			tradeid = '', 
			withdraw_type = 0,
			withdraw_value = 0,
			begin_value = 0,
			end_value = 0,
            service_fee = 0,    --手续费，单位：分
            current_state = 0,
            handle_time = 0,
			complete_time = 0,
			remark = '',
			limit_chipvalue = 0,	--提现时的打码限额值
			phase_chipvalue = 0,	--提现时的阶段打码值
			create_time = 0,
		},
		storage = 3,
    },
    rm_gamerecord = {     --游戏输赢记录表
        fields = {
			rid = 0,
			keyid = 0,
			gamename = '', 
			total_win = 0,
			total_lose = 0,
			create_time = 0,
		},
		storage = 3,
    },
	rm_giverecord = {     --赠送记录表
        fields = {
			rid = 0,
			keyid = 0,
			recvrid = 0,
			undorid = 0,
			tradeid = '',
			sendname = '',
			recvname = '',
			give_type = 0,
			give_value = 0,
			begin_value = 0,
			end_value = 0,
			current_state = 0,
			remark = '',
			get_time = 0,
			undo_time = 0,
			create_time = 0,
		},
		storage = 3,
    },
    rm_messagerecord = {
    	fields = {
    		rid = 0, 
			keyid = 0,
			sendrid = 0,
			destorid = 0, 
			destoname = '',
			msg = '',
			message_sendtime = 0,
			create_time = 0,
    	},
    	storage = 3,
    },
}

return dbstruct
